package com.joysuch.wwyt.bp.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * @Author ZhangDong
 * @Date 2021/1/12 14:11
 */
@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Entity
@Table(name = "wwyt_bp_device_facility_detect_record")
@SQLDelete(sql = "update wwyt_bp_device_facility_detect_record set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_bp_device_facility_detect_record set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
@Data
public class BpDeviceFacilityDetectRecord {

    @Id
    @GeneratedValue(strategy = IDENTITY)
    private Long id;
    @ApiModelProperty("设备装置id")
    private Long deviceFacilityId;
    @ApiModelProperty("检测日期")
    private LocalDate detectDate;
    @ApiModelProperty("登记时间")
    private LocalDateTime registerTime;
    @ApiModelProperty("内部检测人")
    private Long innerUserId;
    @ApiModelProperty("外部检测人姓名")
    private String outerUserName;
    @ApiModelProperty("所属部门")
    private Long departId;
    @ApiModelProperty("外部单位名称")
    private String outerUnitName;
    @ApiModelProperty("登记人")
    private Long registerUserId;
    @ApiModelProperty("附件")
    private String attachmentJson;
    @ApiModelProperty("检测内容")
    private String detectContent;
    @ApiModelProperty("检测结果")
    private String detectResult;
    @ApiModelProperty("检测状态")
    private String detectStatus;
    //下次检测日期
    private Date detectValidityDate;

    //通用字段
    @ApiModelProperty("创建人")
    @org.springframework.data.annotation.CreatedBy
    @JsonIgnore
    private Long createBy;
    @ApiModelProperty("创建时间")
    @org.springframework.data.annotation.CreatedDate
    @JsonIgnore
    private LocalDateTime createTime;
    @ApiModelProperty("更新人")
    @org.springframework.data.annotation.LastModifiedBy
    @JsonIgnore
    private Long updateBy;
    @ApiModelProperty("更新时间")
    @org.springframework.data.annotation.LastModifiedDate
    @JsonIgnore
    private LocalDateTime updateTime;
    @ApiModelProperty("租户")
    @JsonIgnore
    private Long tenentId;
    @ApiModelProperty("组织机构代码")
    @JsonIgnore
    private String orgCode;
    @ApiModelProperty("删除标记")
    @JsonIgnore
    private String deleteFlag;
}
